<?php

class App_View_Helper_MenuClass
{
    function menuClass($type, $controller, $action = '')
    {
        $fc = Zend_Controller_Front::getInstance();
        // current controller name
        $c_name = $fc->getRequest()->getControllerName();
        // current action name
        $a_name = $fc->getRequest()->getActionName();
        if (is_array($controller)) {
	        // return menu class
	        switch ($type) {
	        	case 'menu':
	        		return (array_search ( $c_name, $controller ) !== false) ? 'current': 'select';
	        		break;
	        	case 'submenu':
	        		return (array_search ( $c_name, $controller ) !== false) ? 'sub_active': 'sub';
	        		break;
	        }
        }
        // return menu class
        switch ($type) {
        	case 'menu':
        		return ($c_name == $controller) ? 'current': 'select';
        		break;
        	case 'submenu':
        		return ($c_name == $controller) ? 'sub_active': 'sub';
        		break;
        	case 'item':
        		return (($c_name == $controller) && ($a_name == $action)) ? 'current_sub': '';
        		break;
        	default:
        		return '';
        		break;
        }
    }

}